package utils

import (
	"github.com/gin-gonic/gin"
	"leading/models"
	"os"
	"path"
)

// 获取文件名
func GetFileExt(fileName string) string {
	ext := path.Ext(fileName)
	return ext
}

// 获取文件大小
func GetFileInfo(filePath string) (int64, error) {
	fileInfo, err := os.Stat(filePath)
	if err != nil {
		return 0, err
	}
	return fileInfo.Size(), nil
}

// 获取user
func GetUser(c *gin.Context) models.UserModel {
	var user models.UserModel
	Res, _ := c.Get("user")
	user = Res.(models.UserModel)
	return user
}
